﻿using System.Collections.Generic;
using WMM.Tapioca.Linkbase;
using WMM.Tapioca.Taxonomy;

namespace WMM.Tapioca.Taxonomy
{
	/// <summary>
	/// The representation of a summation concept used in a calculation arc.
	/// </summary>
	/// <remarks>>
	/// Section 5.2.5.2 of the XBRL 2.1 Specification discusses summation concepts.
	/// </remarks>
	public class Summation
	{
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

		/// <summary>
		/// The locator for the summation concept.
		/// </summary>
		public Locator SummationLocator
		{
			get;
			private set;
		}

		/// <summary>
        /// The network graph for the summation concept.
		/// </summary>
        public NetworkGraph NetworkGraphSummation
		{
			get;
			private set;
		}

		/// <summary>
		/// A collection of <see cref="Locator"/> objects for the contributing concepts.
		/// </summary>
		public List<Locator> ContributingLocators
		{
			get;
			private set;
		}

		
        internal Summation(NetworkGraph ng, Locator summationLocator)
		{
            log.Debug("Creating Summation:" + summationLocator.Label);

            this.NetworkGraphSummation = ng;
			this.SummationLocator = summationLocator;
			this.ContributingLocators = new List<Locator>();
		}

		
		internal void AddContributingConceptLocator(Locator contributingLocator)
		{
            if (!ContributingLocators.Contains(contributingLocator))
            {
                ContributingLocators.Add(contributingLocator);
            }
		}
	}
}
